bitkeeper revision 1.1041.1.12 (40eae094p4Hi_HGiXIC_gBESK2nm0g)
authordjm@kirby.fc.hp.com <djm@kirby.fc.hp.com>
Tue, 6 Jul 2004 17:25:40 +0000 (17:25 +0000)
committerdjm@kirby.fc.hp.com <djm@kirby.fc.hp.com>
Tue, 6 Jul 2004 17:25:40 +0000 (17:25 +0000)
Move most of DOM0_GETDOMAININFO back to common, leaving just
getting the context in machdep code.

xen/arch/x86/dom0_ops.c
xen/common/dom0_ops.c

index 1ec26d583d6271316e3e4f5c218aacf726ef1881..4ee83fb6ad443812184851a3488dedd883793f38 100644 (file)
@@ -79,127 +79,6 @@ long arch_do_dom0_op(dom0_op_t *op, dom0_op_t *u_dom0_op)
     }
     break;
 
-    case DOM0_GETDOMAININFO:
-    { 
-        full_execution_context_t *c;
-        struct domain            *d;
-        unsigned long             flags;
-        int                       i;
-
-        read_lock_irqsave(&tasklist_lock, flags);
-
-        for_each_domain ( d )
-        {
-            if ( d->domain >= op->u.getdomaininfo.domain )
-                break;
-        }
-
-        if ( (d == NULL) || !get_domain(d) )
-        {
-            read_unlock_irqrestore(&tasklist_lock, flags);
-            ret = -ESRCH;
-            break;
-        }
-
-        read_unlock_irqrestore(&tasklist_lock, flags);
-
-        op->u.getdomaininfo.domain = d->domain;
-        strcpy(op->u.getdomaininfo.name, d->name);
-        
-        op->u.getdomaininfo.flags =
-            (test_bit(DF_DYING,     &d->flags) ? DOMFLAGS_DYING    : 0) |
-            (test_bit(DF_CRASHED,   &d->flags) ? DOMFLAGS_CRASHED  : 0) |
-            (test_bit(DF_SHUTDOWN,  &d->flags) ? DOMFLAGS_SHUTDOWN : 0) |
-            (test_bit(DF_CTRLPAUSE, &d->flags) ? DOMFLAGS_PAUSED   : 0) |
-            (test_bit(DF_BLOCKED,   &d->flags) ? DOMFLAGS_BLOCKED  : 0) |
-            (test_bit(DF_RUNNING,   &d->flags) ? DOMFLAGS_RUNNING  : 0);
-
-        op->u.getdomaininfo.flags |= d->processor << DOMFLAGS_CPUSHIFT;
-        op->u.getdomaininfo.flags |= 
-            d->shutdown_code << DOMFLAGS_SHUTDOWNSHIFT;
-
-        op->u.getdomaininfo.tot_pages   = d->tot_pages;
-        op->u.getdomaininfo.max_pages   = d->max_pages;
-        op->u.getdomaininfo.cpu_time    = d->cpu_time;
-        op->u.getdomaininfo.shared_info_frame = 
-            __pa(d->shared_info) >> PAGE_SHIFT;
-
-        if ( op->u.getdomaininfo.ctxt != NULL )
-        {
-            if ( (c = kmalloc(sizeof(*c))) == NULL )
-            {
-                ret = -ENOMEM;
-                put_domain(d);
-                break;
-            }
-
-            if ( d != current )
-                domain_pause(d);
-
-            c->flags = 0;
-            memcpy(&c->cpu_ctxt, 
-                   &d->shared_info->execution_context,
-                   sizeof(d->shared_info->execution_context));
-            if ( test_bit(DF_DONEFPUINIT, &d->flags) )
-                c->flags |= ECF_I387_VALID;
-            memcpy(&c->fpu_ctxt,
-                   &d->thread.i387,
-                   sizeof(d->thread.i387));
-            memcpy(&c->trap_ctxt,
-                   d->thread.traps,
-                   sizeof(d->thread.traps));
-#ifdef ARCH_HAS_FAST_TRAP
-            if ( (d->thread.fast_trap_desc.a == 0) &&
-                 (d->thread.fast_trap_desc.b == 0) )
-                c->fast_trap_idx = 0;
-            else
-                c->fast_trap_idx = 
-                    d->thread.fast_trap_idx;
-#endif
-            c->ldt_base = d->mm.ldt_base;
-            c->ldt_ents = d->mm.ldt_ents;
-            c->gdt_ents = 0;
-            if ( GET_GDT_ADDRESS(d) == GDT_VIRT_START )
-            {
-                for ( i = 0; i < 16; i++ )
-                    c->gdt_frames[i] = 
-                        l1_pgentry_to_pagenr(d->mm.perdomain_pt[i]);
-                c->gdt_ents = 
-                    (GET_GDT_ENTRIES(d) + 1) >> 3;
-            }
-            c->guestos_ss  = d->thread.guestos_ss;
-            c->guestos_esp = d->thread.guestos_sp;
-            c->pt_base   = 
-                pagetable_val(d->mm.pagetable);
-            memcpy(c->debugreg, 
-                   d->thread.debugreg, 
-                   sizeof(d->thread.debugreg));
-            c->event_callback_cs  =
-                d->event_selector;
-            c->event_callback_eip =
-                d->event_address;
-            c->failsafe_callback_cs  = 
-                d->failsafe_selector;
-            c->failsafe_callback_eip = 
-                d->failsafe_address;
-
-            if ( d != current )
-                domain_unpause(d);
-
-            if ( copy_to_user(op->u.getdomaininfo.ctxt, c, sizeof(*c)) )
-                ret = -EINVAL;
-
-            if ( c != NULL )
-                kfree(c);
-        }
-
-        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )     
-            ret = -EINVAL;
-
-        put_domain(d);
-    }
-    break;
-
     case DOM0_SHADOW_CONTROL:
     {
         struct domain *d; 
@@ -221,3 +100,55 @@ long arch_do_dom0_op(dom0_op_t *op, dom0_op_t *u_dom0_op)
 
     return ret;
 }
+
+void arch_getdomaininfo_ctxt(struct domain *d, full_execution_context_t *c)
+{ 
+    int i;
+
+    c->flags = 0;
+    memcpy(&c->cpu_ctxt, 
+           &d->shared_info->execution_context,
+           sizeof(d->shared_info->execution_context));
+    if ( test_bit(DF_DONEFPUINIT, &d->flags) )
+        c->flags |= ECF_I387_VALID;
+    memcpy(&c->fpu_ctxt,
+           &d->thread.i387,
+           sizeof(d->thread.i387));
+    memcpy(&c->trap_ctxt,
+           d->thread.traps,
+           sizeof(d->thread.traps));
+#ifdef ARCH_HAS_FAST_TRAP
+    if ( (d->thread.fast_trap_desc.a == 0) &&
+         (d->thread.fast_trap_desc.b == 0) )
+        c->fast_trap_idx = 0;
+    else
+        c->fast_trap_idx = 
+            d->thread.fast_trap_idx;
+#endif
+    c->ldt_base = d->mm.ldt_base;
+    c->ldt_ents = d->mm.ldt_ents;
+    c->gdt_ents = 0;
+    if ( GET_GDT_ADDRESS(d) == GDT_VIRT_START )
+    {
+        for ( i = 0; i < 16; i++ )
+            c->gdt_frames[i] = 
+                l1_pgentry_to_pagenr(d->mm.perdomain_pt[i]);
+        c->gdt_ents = 
+            (GET_GDT_ENTRIES(d) + 1) >> 3;
+    }
+    c->guestos_ss  = d->thread.guestos_ss;
+    c->guestos_esp = d->thread.guestos_sp;
+    c->pt_base   = 
+        pagetable_val(d->mm.pagetable);
+    memcpy(c->debugreg, 
+           d->thread.debugreg, 
+           sizeof(d->thread.debugreg));
+    c->event_callback_cs  =
+        d->event_selector;
+    c->event_callback_eip =
+        d->event_address;
+    c->failsafe_callback_cs  = 
+        d->failsafe_selector;
+    c->failsafe_callback_eip = 
+        d->failsafe_address;
+}
index 28b2671e5fd50972cb57db2b8ac69f916600264d..fcec8991b2d06ac302d31dd14190a48a84c4bda4 100644 (file)
@@ -25,6 +25,7 @@
 
 extern unsigned int alloc_new_dom_mem(struct domain *, unsigned int);
 extern long arch_do_dom0_op(dom0_op_t *op, dom0_op_t *u_dom0_op);
+extern void arch_getdomaininfo_ctxt(struct domain *, full_execution_context_t *);
 
 long do_dom0_op(dom0_op_t *u_dom0_op)
 {
@@ -254,6 +255,81 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     }
     break;
 
+    case DOM0_GETDOMAININFO:
+    { 
+        full_execution_context_t *c;
+        struct domain            *d;
+        unsigned long             flags;
+
+        read_lock_irqsave(&tasklist_lock, flags);
+
+        for_each_domain ( d )
+        {
+            if ( d->domain >= op->u.getdomaininfo.domain )
+                break;
+        }
+
+        if ( (d == NULL) || !get_domain(d) )
+        {
+            read_unlock_irqrestore(&tasklist_lock, flags);
+            ret = -ESRCH;
+            break;
+        }
+
+        read_unlock_irqrestore(&tasklist_lock, flags);
+
+        op->u.getdomaininfo.domain = d->domain;
+        strcpy(op->u.getdomaininfo.name, d->name);
+        
+        op->u.getdomaininfo.flags =
+            (test_bit(DF_DYING,     &d->flags) ? DOMFLAGS_DYING    : 0) |
+            (test_bit(DF_CRASHED,   &d->flags) ? DOMFLAGS_CRASHED  : 0) |
+            (test_bit(DF_SHUTDOWN,  &d->flags) ? DOMFLAGS_SHUTDOWN : 0) |
+            (test_bit(DF_CTRLPAUSE, &d->flags) ? DOMFLAGS_PAUSED   : 0) |
+            (test_bit(DF_BLOCKED,   &d->flags) ? DOMFLAGS_BLOCKED  : 0) |
+            (test_bit(DF_RUNNING,   &d->flags) ? DOMFLAGS_RUNNING  : 0);
+
+        op->u.getdomaininfo.flags |= d->processor << DOMFLAGS_CPUSHIFT;
+        op->u.getdomaininfo.flags |= 
+            d->shutdown_code << DOMFLAGS_SHUTDOWNSHIFT;
+
+        op->u.getdomaininfo.tot_pages   = d->tot_pages;
+        op->u.getdomaininfo.max_pages   = d->max_pages;
+        op->u.getdomaininfo.cpu_time    = d->cpu_time;
+        op->u.getdomaininfo.shared_info_frame = 
+            __pa(d->shared_info) >> PAGE_SHIFT;
+
+        if ( op->u.getdomaininfo.ctxt != NULL )
+        {
+            if ( (c = kmalloc(sizeof(*c))) == NULL )
+            {
+                ret = -ENOMEM;
+                put_domain(d);
+                break;
+            }
+
+            if ( d != current )
+                domain_pause(d);
+
+            arch_getdomaininfo_ctxt(d,c);
+
+            if ( d != current )
+                domain_unpause(d);
+
+            if ( copy_to_user(op->u.getdomaininfo.ctxt, c, sizeof(*c)) )
+                ret = -EINVAL;
+
+            if ( c != NULL )
+                kfree(c);
+        }
+
+        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )     
+            ret = -EINVAL;
+
+        put_domain(d);
+    }
+    break;
+
     case DOM0_GETPAGEFRAMEINFO:
     {
         struct pfn_info *page;